#ifndef _LOG_H
#define _LOG_H

#define LOG_LEVEL_DEBUG "DEBUG"
#define LOG_LEVEL_INFO  "INFO "
#define LOG_LEVEL_ERR   "ERROR"

#define debug_log(level, fmt, ...)\
do\
{\
    time_t t = time( NULL );   \
    char tmpBuf[20];   \
    if(!g_log_fp) break;\
    strftime(tmpBuf, sizeof(tmpBuf), "%Y%m%d %H:%M:%S", localtime(&t));\
    fprintf(g_log_fp, "%s %s [%s %d][%s](%d) " fmt "\n", tmpBuf,  level, __FILE__, __LINE__, __FUNCTION__, GetCurrentProcessId(), ##__VA_ARGS__);\
    fflush(g_log_fp); \
}while(0)

#define dli(fmt, ...) debug_log(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)

#define lfi dli("Enter...")

#define Return \
    dli("Exit.");\
    return

#endif /* end of include guard */
